﻿using Microsoft.EntityFrameworkCore;
using mozhi.smarterp.BasicData.Currencies;
using mozhi.smarterp.BasicData.Customers;
using mozhi.smarterp.BasicData.Employees;
using mozhi.smarterp.BasicData.ExpenseItems;
using mozhi.smarterp.BasicData.NumberRules;
using mozhi.smarterp.BasicData.Organizations;
using mozhi.smarterp.BasicData.PaymentTerms;
using mozhi.smarterp.BasicData.Products;
using mozhi.smarterp.BasicData.TaxRates;
using mozhi.smarterp.BasicData.Units;
using mozhi.smarterp.BasicData.Warehouses;
using Mozhi.Abp.Module.DataLinkage;
using Mozhi.Abp.Module.DataLinkage.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EntityFrameworkCore;

namespace mozhi.smarterp.BasicData.EntityFrameworkCore;

[ReplaceDbContext(typeof(IDataLinkageDbContext))]
[ConnectionStringName(BasicDataDbProperties.ConnectionStringName)]
public class BasicDataDbContext : AbpDbContext<BasicDataDbContext>, IBasicDataDbContext, IDataLinkageDbContext
{
    /* Add DbSet for each Aggregate Root here. Example:
     * public DbSet<Question> Questions { get; set; }
     */

    #region
    public DbSet<DataLinkage> DataLinkages { get; set; }
    #endregion

    public DbSet<Organization> Organizations { get; set; }

    public DbSet<Product> Products { get; set; }

    public DbSet<Supplier> Suppliers { get; set; }

    public DbSet<Customer> Customers { get; set; }

    public DbSet<CustomerContactItem> CustomerContactItems {  get; set; }

    public DbSet<Employee> Employees { get; set; }

    public DbSet<ExpenseItem> ExpenseItems { get; set; }

    public DbSet<Currency> Currencies { get; set; }

    public DbSet<ExchangeRate> ExchangeRate { get; set; }

    public DbSet<Tag> Tags { get; set; }

    public DbSet<Unit> Units { get; set; }

    public DbSet<TaxRate> TaxRates { get; set; }

    public DbSet<ProductAuxiliaryUnit> ProductAuxiliaryUnits { get; set; }

    public DbSet<DocumentNumberRule> DocumentNumberRules { get; set; }

    public DbSet<Warehouse> Warehouses { get; set; }

    public DbSet<PaymentTerm> PaymentTerms { get; set; }

    public BasicDataDbContext(DbContextOptions<BasicDataDbContext> options)
        : base(options)
    {

    }

    protected override void OnModelCreating(ModelBuilder builder)
    {
        base.OnModelCreating(builder);

        builder.ConfigureDataLinkage();

        builder.ConfigureBasicData();
    }
}
